#ifndef MODEL_BOUNDING_VOLUME_H
#define MODEL_BOUNDING_VOLUME_H

#include <NxShapeDesc.h>
#include <NxBoxShapeDesc.h>
#include <NxTriangleMeshDesc.h>
#include <NxTriangleMeshShapeDesc.h>
#include <NxConvexMeshDesc.h>
#include <NxConvexShapeDesc.h>
#include <NxVec3.h>
#include <assimp/aiScene.h>
#include <assimp/assimp.h>

#include "../Util/Log.h"
#include "ModelParamAiInfo.h"

class ModelBoundingVolume {
public:
	enum SHAPETYPE {BOX_SHAPE, TRIANGLE_MESH_SHAPE, CONVEX_SHAPE};

	ModelBoundingVolume(NxPhysicsSDK *sdk);
	ModelBoundingVolume(NxPhysicsSDK *sdk, Log *log);
	~ModelBoundingVolume();

	void CalcBoundingVolume(SHAPETYPE shapetype, const ModelAiParamInfo &modelAiInfo, aiMatrix4x4 parentTransformation, float modelScaleFactor);

	NxShapeDesc *GetShapeDesc();
	NxBoxShapeDesc *IsBoxShape();
	NxTriangleMeshShapeDesc *IsTriangleMeshShape();
	NxConvexShapeDesc *IsConvexShape();

private:
	Log *errLog;

	NxPhysicsSDK *sdk;
	SHAPETYPE modelShapeType;

	NxShapeDesc *shapeDescPointer;

	bool CalcBoxShape(const ModelAiParamInfo &modelAiInfo, aiMatrix4x4 parentTransformation, NxShapeDesc *&shapeDescPointer, float scalefactor);
	bool CalcTriangleMeshShapes(const ModelAiParamInfo &modelAiInfo, aiMatrix4x4 parentTransformation, NxShapeDesc *&shapeDescPointer, float scalefactor);
	bool CalcConvexShapes(const ModelAiParamInfo &modelAiInfo, aiMatrix4x4 parentTransformation, NxShapeDesc *&shapeDescPointer, float scalefactor);
};

#endif //MODEL_BOUNDING_VOLUME_H
